import request from '../../utils/request.js'
const state = {
  recommendData : {} ,
  teaHouseData : {} ,
  eventData : {},
  cartList : uni.getStorageSync('cartList') || []
}
const mutations = {
  SET_RECOMMENDDATA(state,recommendData){
    state.recommendData = recommendData
  },
  SET_TEAHOUSEDATA(state,teaHouseData){
    state.teaHouseData = teaHouseData
  },
  SET_EVENTDATA(state,eventData){
    state.eventData = eventData
  }
}
const actions = {
  // 首页推荐数据
  async getRecommendData ({commit}) {
    const res = await request('/getGoodsDetail')
    console.log(res);
    commit('SET_RECOMMENDDATA',res.goodsDetail)
  },
  // 中国茶仓数据
  async getTeaHouseData ({commit}) {
    const res = await request('/getTeaHouse')
    // console.log(res);
    commit('SET_TEAHOUSEDATA',res.list)
  },
  // T豆购
  async getEventData ({commit}) {
    const res = await request('/getEvent')
    console.log(res);
    commit('SET_EVENTDATA',res.list)
  }
}
const getters = {
  
}

export default {
  state,
  mutations,
  actions,
  getters,
  namespaced:true
}